package com.bookstore.Controller;

import com.bookstore.Domain.Address;
import com.bookstore.Domain.Code;
import com.bookstore.Domain.Result;
import com.bookstore.Service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author 未来
 */
@CrossOrigin
@Controller
@RequestMapping("/address")
public class AddressController {

    private final AddressService addressServic;

    @Autowired
    public AddressController(AddressService service) {
        this.addressServic = service;
    }

    /**
     * 存储新数据
     */
    @PostMapping
    @ResponseBody
    public Result save(@RequestBody Address address) {
        boolean flag = addressServic.saveAddress(address);
        return new Result(flag ? Code.SAVE_OK : Code.SAVE_ERR, flag);
    }

}
